home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_exim.idb / usr / freeware / bin / exiwhat.z / exiwhat
Encoding:
Text File  |  1999-01-26  |  2.6 KB  |  73 lines

  1. #! /bin/sh
  2.  
  3. # Copyright (c) 1996 University of Cambridge.
  4. # See the file NOTICE for conditions of use and distribution.
  5.  
  6.  
  7. # Shell script for seeing what the exim processes are doing. It gets rid
  8. # of the old process log, then sends SIGUSR1 to all exim processes to get
  9. # them to write their state to the log. Then it displays the contents of
  10. # the log.
  11.  
  12. # The following lines are generated from Exim's configuration file when
  13. # this source is built into a script, but you can subsequently edit them
  14. # without rebuilding things, as long are you are careful not to overwrite
  15. # the script in the next Exim rebuild/install. However, it's best to
  16. # arrange your build-time configuration file to get the correct values.
  17. # The variable ps_cmd is the path to the "ps" command, ps_arg is the argument
  18. # for the ps command, kill_arg is the argument for the kill command to send
  19. # SIGUSR1 (at least one OS requires a numeric value), and egrep_arg is the
  20. # argument for egrep to find the instances of exim in the ps output.
  21.  
  22. ps_cmd=/bin/ps
  23. ps_arg=-e
  24. kill_arg=-USR1
  25. egrep_arg=' exim( |$)'
  26.  
  27. # Determine where the spool directory is. The strings /usr/freeware/lib/exim/configure and
  28. # /usr/freeware/bin below are replaced by their compile-time settings when
  29. # this source is build into a script. Search for an exim_path setting
  30. # in the configure file; otherwise use the bin directory. Call that version
  31. # of Exim to find the spool directory.
  32.  
  33. config=/usr/freeware/lib/exim/configure
  34.  
  35. # Add code here to redefine "config" if an alternative configuration file
  36. # should be used in some circumstances.
  37.  
  38. exim_path=`grep '^[      ]*exim_path' $config | sed 's/.*=[       ]*//'`
  39. if test "$exim_path" = ""; then exim_path=/usr/freeware/bin/exim; fi
  40. spool_directory=`$exim_path -C /usr/freeware/lib/exim/configure -bP spool_directory | sed 's/.*=[  ]*//'`
  41.  
  42. # Determine if the log file path is set.
  43.  
  44. log_file_path=`$exim_path -C /usr/freeware/lib/exim/configure -bP log_file_path | sed 's/.*=[  ]*//'`
  45.  
  46. # If log_file_path is empty, then the log that Exim writes when sent the
  47. # SIGUSR1 signal is called "processlog" in the directory called "log" in the
  48. # spool directory. Otherwise we fish out the directory from the given path,
  49. # and also the name of the log.
  50.  
  51. if [ "$log_file_path" = "" ]; then
  52.   log=$spool_directory/log/processlog
  53. else
  54.   log=`echo $log_file_path | sed 's/%s/process/'`
  55. fi
  56.  
  57. # Now do the job.
  58.  
  59. /bin/rm -f ${log}
  60. if [ -f ${log} ]; then
  61.   echo "** Failed to remove ${log}"
  62.   exit 1
  63. fi
  64.  
  65. $ps_cmd $ps_arg | egrep "$egrep_arg" | cut -c1-6 | sed -e "s/^/kill $kill_arg /" | sh
  66.  
  67. sleep 1
  68.  
  69. if [ ! -s ${log} ] ; then echo "No exim process data" ;
  70.   else cut -c20-999 ${log} ; fi
  71.  
  72. # End of exiwhat
  73.